var express = require('express');
var router = express.Router();

// router.get('/', function(req, res, next) {
//   var arr =[1,2,3,4,5,6,7,8]
//   res.render('index', { title: 'index', arr });
// });

// 实际项目中的做法
var db = {
  getData (req,res,next) {
    var arr =[1,2,3,4,5,6,7,8]
    res.locals = {title: 'index', arr}
    next()
  }
}

router.get('/',db.getData, function(req, res, next) {
  res.render('index');
});

module.exports = router;
